<?php

/**
 *  +----------------------------------------------------------------------
 *  | 文件功能：HomeController.php：前端首页方法控制器
 *  +----------------------------------------------------------------------
 *  | Copyright (c) 2022~2024 https://www.huihuiv.com All rights reserved. 
 *  +----------------------------------------------------------------------
 *  | Create At: 2024年03月14日 23:50:46
 *  +----------------------------------------------------------------------
 *  | Author: 半壶水 <star@cqshanwen.com>
 *  +----------------------------------------------------------------------
 */

namespace App\Http\Controllers\Api;

use App\Librarys\Message;
use App\Models\ContentSimpleModel;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class HomeController extends BaseController
{
    protected Request $request;
    protected Model $contentSimpleModel;

    public function __construct(Request $request, ContentSimpleModel $contentSimpleModel)
    {
        $this->request = $request;
        $this->contentSimpleModel = $contentSimpleModel;
    }

    /**
     * 获取幻灯片列表
     *
     * @return JsonResponse
     */
    public function get_swiper_list(): JsonResponse
    {
        // 获取显示数量
        $num = $this->request->num;
        // 获取Swiper列表
        $swiperList = $this->contentSimpleModel->where(['is_banner' => 1])->limit($num)->get();
        return Message::show(true, '获取成功', $swiperList);
    }

}
